<?php
global $VALUTA, $USER_SETTING;
?>
<h2>Полная информация об операции</h2>

<table class='list operations' cellspacing=0 style="width:auto;">
	<thead>
		<tr>
			<th>Участник</th>
			<th>Дата</th>
			<th>Сумма</th>
			<th>Курс</th>
			<th>Мавро</th>
			<th>Срок разморозки</th>
			<th>Сумма при разморозке</th>
			<th>Вид и место хранения</th>
			<th>Дополнительно</th>
		</tr>
	</thead>
	<tbody>
		<?php foreach($opers as $o) {
			$type_class = isBuy($o) ? 'buy' : 'sell';
			$super = $o['depo'] && substr($o['percent'], -1) == 5 ? "super" : '';
			$frozen_gray = $o['frozen_date'] && $o['frozen_date'] < date('Y-m-d') ? 'gray' : '';
			$show_frozen = $o['frozen_summ'] && $o['frozen_date'];
			?>
			<tr <?php if(@$o['selected_view']) echo "class='selected_view'"; ?>>
				<td style='text-align:left'><?php echo @$o['user']['fio']." (".@$o['user']['email'].")"?></td>
				<td class='<?=($o['bonus']) ? 'bonus' : ''?> o_date'><?=$o['day']?>.<?=$o['month']?>.<?=$o['year']?></td>
				<td class='<?=($o['bonus']) ? 'bonus' : ''?> <?=$type_class?> o_summ'><?=$o['summ']?> <?=$VALUTA[$o['valuta']]?></td>
				<td class='<?=($o['bonus']) ? 'bonus' : ''?> <?=$type_class?> o_kurs'>
					<?php if($o['type'] == 'week') {?>
						<?=$o['percent']?>%
					<?php } else { ?>
						<?php if($o['kurs_valuta'] > 0 && $o['kurs_valuta'] != 1) echo $o['kurs_valuta']." / "; ?>
						<?=$o['valuta']?> <?=$o['kurs']?> <?=$VALUTA[$o['mavro_valuta']]?> (<?=$o['percent']?>%)
					<?php }?>
				</td>
				<td class='<?=($o['bonus']) ? 'bonus' : ''?> <?=$type_class?> o_mavro'>
					<?php if($o['type'] != 'week') {?>
						<?=$o['mavro']?> <?=$o['mavro_valuta']?> <?php if($o['depo']) echo "(".$o['depo']."m ".$super.")";?>
					<?php } ?>
				</td>
				<td class='<?=($is_bonus ? 'bonus' : '').' '.$frozen_gray?>'><?=$show_frozen ? getPrintDate($o['frozen_date']) : ''?></td>
				<td class='<?=($is_bonus ? 'bonus' : '').' '.$frozen_gray?>'><?=$show_frozen ? (number_format($o['frozen_summ'], 2, $USER_SETTING['znak_drob'], ' ')).' '.$VALUTA[$o['mavro_valuta']] : ''?></td>
				<td class='<?=($o['bonus']) ? 'bonus' : ''?> o_hranen'><?=$o['hranen']?></td>
				<td class='o_dop'><?=$o['dop']?></td>
			</tr>
		<?php } ?>
	</tbody>
</table>


<?php if(count($platezhi)) { ?>
<br><br>
	<h2>Связанные платежи</h2>

<table class='list' cellspacing=0 style="width:auto;">
	<thead>
		<tr>
			<th>Счёт</th>
			<th>Дата перевода</th>
			<th>Дата поступления</th>
			<th>От кого</th>
			<th>Кому</th>
			<th>Валюта</th>
			<th>Сумма</th>
			<th>Комиссия</th>
			<th>Итого</th>
			<th>Файлы</th>
			<th>Комментарий</th>
		</tr>
	</thead>
	<tbody>
	<?php
		foreach($platezhi as $p) 
		{
			$class = isPlatezhBuy($p) ? 'buy' : 'sell';
			?>
			<tr>
				<td><?=$p['schet_name']?></td>
				<td align=center><?=date("d.m.Y", strtotime($p['from_date']))?></td>
				<td align=center><?=date("d.m.Y", strtotime($p['to_date']))?></td>
				<td><?=@$p['user_from']?></td>
				<td><?=@$p['user_to']?></td>
				<td align=center class='<?=$class?>'><?=$VALUTA[$p['valuta']]?></td>
				<td align=right class='<?=$class?>'><?=number_format($p['summ'], 2, $USER_SETTING['znak_drob'], ' ')?></td>
				<td align=right class='<?=$class?>'><?=number_format($p['komiss'], 2, $USER_SETTING['znak_drob'], ' ')?></td>
				<td align=right class='<?=$class?>'><?=number_format($p['itogo'], 2, $USER_SETTING['znak_drob'], ' ')?></td>
				<td><?php
				for($i = 1; $i <= 5; $i++)
				{
					$filename = $p['file'.$i."_comment"] ? $p['file'.$i."_comment"] : "Файл ".$i;
					if($p['file'.$i]) {?>
					<a href='<?=UPLOAD_PATH.$p['file'.$i]?>' target=_blank><?=$filename?></a><br>
					<? }
				}
				?></td>
				<td><?=nl2br(htmlspecialchars($p['comment']))?></td>
			</tr>
			<?php
	}

	 ?>
	</tbody>
</table>

<?php } ?>


